import { useDetail, useList } from "@/hooks";
import { getUserInfoUrl } from "@/command/apiTool";
import { useRoute } from "vue-router";
export const useRequest = () => {
  const position = localStorage.getItem("positionData") as string;
  const positionJSON = JSON.parse(position) as {
    latitude: string;
    longitude: string;
  };
  const route = useRoute();
  // 预约大户详情
  const [queryDhDetail] = useDetail(
    getUserInfoUrl(
      {
        dh: "",
        xh: "/api/h5/richInspection/small/getDetail",
        /* 大户详情:/h5/richInspection/small/getDetail"
          设备列表:/h5/richInspection/small/queryEquipmentListil
          检测情况:/h5/richInspection/small/queryApplyNum?id=4
          推荐:/h5/richInspection/small/suggest?id=4 */
      },
      {
        id: route.query.id,
        lat: positionJSON.latitude,
        lng: positionJSON.longitude,
      }
    ),
    {
      entityName: "",
      entityLogo: "",
      majorName: "",
      address: "",
      introduce: "",
      phone: "",
      jl: "",
      productTypeName: "",
      businessDate: "",
      list: [],
    }
  );

  // 大户检测情况
  const [queryApplyNum] = useDetail(
    getUserInfoUrl(
      {
        dh: "",
        xh: "/api/h5/richInspection/small/queryApplyNum",
      },
      {
        id: route.query.id,
      }
    ),
    {
      acceptNum: "",
      acceptNumYear: [],
      smallApplyNum: "",
      smallApplyNumYear: [],
    }
  );

  const [suggestList] = useDetail(
    getUserInfoUrl(
      {
        dh: "",
        xh: "/api/h5/richInspection/small/suggest",
      },
      {
        id: route.query.id,
      }
    ),
    []
  );

  // 检测设备
  const [deviceList] = useDetail(
    getUserInfoUrl(
      {
        dh: "",
        xh: "/api/h5/richInspection/small/queryEquipmentList",
      },
      {
        id: route.query.id,
      }
    ),
    []
  );

  return {
    queryDhDetail,
    queryApplyNum,
    deviceList,
    suggestList,
  };
};
